﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Myinfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (null == Session["person"])
        {
            Label2.Text = "<script>alert('请登录！');window.location.href='Default.aspx';</script>";
            return;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //上传图片
        FileUpload FU = (FileUpload)FormView2.FindControl("FU");
        string path = FU.FileName;
        string[] file = path.Split('\\');
        string filename = file[file.Length - 1];
        if (filename != "")
        {
            string path1 = Server.MapPath("");
            string ok = path1 + "\\images\\person\\" + filename;
            FU.SaveAs(ok);
            Image igGoods = (Image)FormView2.FindControl("Image1");
            igGoods.ImageUrl = "~/images/person/" + filename;
            TextBox tx = (TextBox)FormView2.FindControl("pimgsTextBox");
            tx.Text = filename;
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        MV.SetActiveView(View1);
       // MV.ActiveViewIndex = 0;
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        MV.SetActiveView(View3);
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        MV.SetActiveView(View2);
    }
    Login lo = new Login();
    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (null == Session["person"]) {
            Label2.Text = "<script>alert('请登录！');window.location.href='Default.aspx';</script>";
            return;
        }
        if (lo.ishave(Session["person"].ToString(), MD5.EncodeMD5(txtoldpwd.Text.Trim())).Equals("1"))
        {
            if (lo.updatepwd(Session["person"].ToString(), MD5.EncodeMD5(this.txtnewpwd.Text.Trim())).Equals("1"))
            {
                Label2.Text = "<script>alert('密码修改成功！');window.location.href='Default.aspx';</script>";
            }
            else {
                Label2.Text = "<script>alert('密码修改失败！');</script>";
            }
        }
        else {
            Label2.Text = "<script>alert('旧密码错误！');</script>";
        }
    }
    protected void UpdateButton_Click(object sender, EventArgs e)
    {

    }
}
